class ApplicationController < ActionController::Base
  include Clearance::Authentication
  protect_from_forgery
  
  
  def getMarkers(city)
    
    markers = Array.new
    
    if not city.nil?
      @city_name = city
    end
    
    if signed_in?
      current_user.subscription.to_gmaps4rails do |subscription, marker|
        @weather = Weather.get_weather(subscription.city)     
        markers.push({  
          description: render_to_string(:partial => 'weathers/show'),
          lng: @weather['location']['longitude'], 
          lat: @weather['location']['latitude'], 
          picture: @weather['forecast']['now']['icon'], 
          width: "30", 
          height: "30",
          rich_marker: render_to_string(:partial => "/weathers/now_on_map"),
          title: @weather['location']['city']
        })
      end 
    end
    

    if not city.nil?
      @weather = Weather.get_weather(@city_name)
  
      markers.push({  description: render_to_string(:partial => 'weathers/show'), 
                       title: @weather['location']['city'], 
                       sidebar: "", 
                       lng: @weather['location']['longitude'], 
                       lat: @weather['location']['latitude'], 
                       picture: @weather['forecast']['now']['icon'], 
                       width: "30", 
                       height: "30",
                       rich_marker: render_to_string(:partial => "/weathers/now_on_map")
                   })
    end
    
    return markers
  end
  
  
end
